package com.sup.menu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sup.common.annotation.Log;
import com.sup.common.core.controller.BaseController;
import com.sup.common.core.domain.AjaxResult;
import com.sup.common.enums.BusinessType;
import com.sup.menu.domain.CooperateMenu;
import com.sup.menu.service.ICooperateMenuService;
import com.sup.common.utils.poi.ExcelUtil;
import com.sup.common.core.page.TableDataInfo;

/**
 * 合作信息表单Controller
 * 
 * @author ruoyi
 * @date 2025-02-13
 */
@RestController
@RequestMapping("/menu/menu")
public class CooperateMenuController extends BaseController
{
    @Autowired
    private ICooperateMenuService cooperateMenuService;

    /**
     * 查询合作信息表单列表
     */
    @PreAuthorize("@ss.hasPermi('menu:menu:list')")
    @GetMapping("/list")
    public TableDataInfo list(CooperateMenu cooperateMenu)
    {
        startPage();
        List<CooperateMenu> list = cooperateMenuService.selectCooperateMenuList(cooperateMenu);
        return getDataTable(list);
    }

    /**
     * 导出合作信息表单列表
     */
    @PreAuthorize("@ss.hasPermi('menu:menu:export')")
    @Log(title = "合作信息表单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CooperateMenu cooperateMenu)
    {
        List<CooperateMenu> list = cooperateMenuService.selectCooperateMenuList(cooperateMenu);
        ExcelUtil<CooperateMenu> util = new ExcelUtil<CooperateMenu>(CooperateMenu.class);
        util.exportExcel(response, list, "合作信息表单数据");
    }

    /**
     * 获取合作信息表单详细信息
     */
    @PreAuthorize("@ss.hasPermi('menu:menu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cooperateMenuService.selectCooperateMenuById(id));
    }

    /**
     * 新增合作信息表单
     */
    @PreAuthorize("@ss.hasPermi('menu:menu:add')")
    @Log(title = "合作信息表单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CooperateMenu cooperateMenu)
    {
        return toAjax(cooperateMenuService.insertCooperateMenu(cooperateMenu));
    }

    /**
     * 修改合作信息表单
     */
    @PreAuthorize("@ss.hasPermi('menu:menu:edit')")
    @Log(title = "合作信息表单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CooperateMenu cooperateMenu)
    {
        return toAjax(cooperateMenuService.updateCooperateMenu(cooperateMenu));
    }

    /**
     * 删除合作信息表单
     */
    @PreAuthorize("@ss.hasPermi('menu:menu:remove')")
    @Log(title = "合作信息表单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cooperateMenuService.deleteCooperateMenuByIds(ids));
    }
}
